home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland Pascal with Objects 7.0 / TDDOC.ZIP / HELPME!.TD < prev    next >
Encoding:
Text File  |  1992-10-27  |  23.1 KB  |  535 lines

  1.                       TURBO DEBUGGER TIPS AND HINTS
  2.                       =============================
  3.  
  4. CONTENTS:
  5. 1.  Answers to common questions
  6. 2.  Turbo Debugger for Windows (TDW), Windows debugging hints
  7. 3.  TDW mouse support
  8. 4.  TD mouse support
  9.  
  10. 1. Answers to common questions
  11. ------------------------------
  12.   Following is a list of the most commonly asked questions about Turbo
  13.   Debugger.
  14.  
  15.   1. How does Turbo Debugger handle screen output for graphics-
  16.      and text-based programs?
  17.  
  18.      There are a number of strategies that can be used to control
  19.      how and when the screen gets refreshed. You should review the
  20.      following tips if you are debugging a program that uses a graphics
  21.      display mode and you want to do either of the following:
  22.  
  23.         - use a Borland pop-up utility such as SideKick or
  24.           Sidekick Plus while inside Turbo Debugger
  25.  
  26.         - run programs from Turbo Debugger's DOS Shell that write
  27.           directly to video memory
  28.  
  29.      The default screen-updating mode, "Swap," causes Turbo Debugger
  30.      to use a single display adapter and display page and swap the
  31.      contents of the user and Turbo Debugger screens in software.
  32.      "Swap" is the slowest method of display swapping, but is the most
  33.      protective and least disruptive.
  34.  
  35.      Pop-up utilities might not appear on the screen if your screen
  36.      updating is set to "Flip," even though they are active and proces-
  37.      sing your keystrokes. You must select "Swap" mode for display
  38.      updating in order for these programs to work properly. Use Turbo
  39.      Debugger's -ds command-line option to do this or use the TDINST
  40.      utility to permanently set this mode. "Swap" mode makes screen
  41.      updating slower, but it ensures that Turbo Debugger's screen
  42.      doesn't interfere with either your program's or any other program's
  43.      display.
  44.  
  45.      You might also need to use "Swap" when you use the DOS Shell
  46.      command or run an editor from within Turbo Debugger. Most programs
  47.      expect to run on video page 0 and don't check to see what
  48.      the current video page is. Turbo Debugger's DOS Shell and any
  49.      editors that Turbo Debugger runs in "Flip" mode don't run from
  50.      video page 0, and the programs might appear to hang, even though
  51.      you will be able to type in keystrokes normally. If this happens,
  52.      use the -ds command-line option when you run Turbo Debugger or
  53.      reinstall Turbo Debugger to use "Swap" instead of "Flip."
  54.  
  55.      If you are debugging a graphics mode application, you must specify
  56.      the -ds command-line option ("Swap" contents), and you might want
  57.      to use Turbo Debugger's -vg command-line option (Graphics Save). This
  58.      option causes additional memory to be set aside for saving the
  59.      entire graphics image your program produces. If you don't use this
  60.      option, a "red cloud" may appear on your program's screen. These
  61.      options can also be set permanently by using the TDINST program.
  62.      The Graphics Save option takes an additional 8K of memory and slows
  63.      screen-swapping.
  64.  
  65.      If you're running a graphics program that changes the EGA or VGA
  66.      palette, make sure you use the -vp command-line option to save the
  67.      palette.
  68.  
  69.   2. Can Turbo Debugger execute other programs while you're still debugging?
  70.  
  71.      The DOS Shell and Edit commands in the Module and File
  72.      windows can swap to disk the program you are debugging in
  73.      order to make room to run DOS or your editor. The default
  74.      amount of memory to swap is 128K. You can use TDINST to set a
  75.      different amount if that's not enough memory to run your editor
  76.      or other programs. Setting the swap size to 0K tells Turbo Debugger
  77.      to swap the entire user program to disk before running the DOS
  78.      command processor.
  79.  
  80.      Only your program gets swapped to disk; Turbo Debugger remains in memory.
  81.  
  82.   3. How can I break out of a program even though interrupts are
  83.      disabled?
  84.  
  85.      If you have an 80386 computer and are using TD386, the -B option
  86.      allows a break even when interrupts are disabled. For example, this
  87.      option enables a break from
  88.  
  89.        CLI
  90.        JMP $
  91.  
  92.   4. Why can't I press Ctrl-Break to get out of a program
  93.      running on a remote machine?
  94.  
  95.      The program running on the remote machine has taken control
  96.      of Interrupt 1B (Ctrl-Break). TDREMOTE and WREMOTE don't take
  97.      back control of Interrupt 1B until you stop execution of the
  98.      running program. To stop execution, run the program to completion
  99.      or press Ctrl-F2 (Program Reset) on the local machine.
  100.  
  101.  
  102.   5. What are some of the syntactic and parsing differences
  103.      between Turbo Debugger's built-in assembler and the
  104.      standalone Turbo Assembler?
  105.  
  106.      A discussion follows this short example program:
  107.  
  108.               .model small
  109.               .data
  110.  
  111.        abc    struc
  112.        mem1   dd      ?
  113.        mem2   db      ?
  114.        mem3   db      "   "
  115.        abc    ends
  116.  
  117.               align   16
  118.        a      abc     <1,2,"xyz">
  119.  
  120.        msg1   db      "testing 1 2 3", 0
  121.        msg2   db      "hello world", 0
  122.        nmptr  dw      msg1
  123.        fmptr  dd      msg1,msg2
  124.        nfmptr dw      fmptr
  125.        xx     dw      seg a
  126.  
  127.               .code
  128.  
  129.               push   cs
  130.               pop    ds
  131.               mov    bx,offset a
  132.               mov    bx,nmptr
  133.               les    si,fmptr
  134.               mov    ah,4ch
  135.               int    21h
  136.               end
  137.  
  138.      Because the assembler expression parser does not accept all legal
  139.      TASM instruction operands, Turbo Debugger assembler expressions
  140.      can be more general than those of TASM and can use multiple levels
  141.      of memory-referencing, much like C and Pascal. However, there are a
  142.      few constructs that you may be used to that you'll have to specify
  143.      differently for the TD assembler expression parser to accept them:
  144.  
  145.        a. Size overrides should always appear inside the
  146.           brackets; PTR is optional after the size. Also, when
  147.           referring to a structure, you must use the name of the
  148.           struc, not the name of the variable:
  149.  
  150.             OK:  [byte ptr bx]   [dword si]        [abc bx]
  151.  
  152.             BAD: byte ptr[bx]    [struc abc bx]    [a bx]
  153.  
  154.        b. You must specify a structure name when accessing the
  155.           members of a structure with a register pointer.
  156.  
  157.             OK:  [abc ptr bx].mem1  [abc bx].mem3 + 1
  158.  
  159.             BAD: [bx].mem1
  160.  
  161.        c. You can't use multiple instances of brackets ([]) unless they are
  162.           adjacent, and you can only follow a bracketed expression with
  163.           a dot and a structure member name or another bracketed
  164.           expression:
  165.  
  166.             OK:  4[bx][si]    [abc bx].mem2
  167.  
  168.             BAD: [bx]4[si]    [bx]+4
  169.  
  170.        d. If you use a register as part of a memory expression
  171.           and you don't specify a size, WORD is assumed:
  172.  
  173.             [bx] is the same as [word bx]
  174.  
  175.        e. You can use any register you want between brackets ([]),
  176.           not just the combinations of BX, BP, SI, and DI allowed in
  177.           instruction operands. For example,
  178.  
  179.             [ax+bx]
  180.             [bx+sp]
  181.  
  182.        f. You can use multiple levels of brackets to follow chains of
  183.           pointers. For example,
  184.  
  185.             [byte [[nfmptr]+4]]
  186.  
  187.        g. Be careful with using registers to access memory locations.
  188.           You might get unexpected results if your segment
  189.           registers are not set up properly. If you don't
  190.           explicitly specify a segment register, Turbo Debugger
  191.           uses the DS register to reference memory.
  192.  
  193.        h. When you do specify a segment register, make sure you
  194.           follow the same rule for size overrides: put it
  195.           INSIDE the brackets, as follows:
  196.  
  197.             OK:  [byte es:di]    [es:fmptr]
  198.  
  199.             BAD: es:[byte di]
  200.  
  201.        i. Use the OFFSET operator to get the address of a
  202.           variable or structure. Turbo Debugger automatically
  203.           supplies the brackets around a variable name if you just type
  204.           the variable name alone.
  205.  
  206.             a            contents of structure a
  207.             [a]          contents of structure a
  208.             offset a     address of structure a
  209.  
  210.        j. You can use the type overrides and the format control
  211.           count to examine any area of memory displayed as you
  212.           wish.
  213.  
  214.             [byte es:bx],10  10 bytes pointed to by es:bx
  215.             [dword ds:si],4  4 dwords pointed to by ds:si
  216.  
  217.           This is very useful when specifying watch expressions.
  218.  
  219.        k. Sometimes you use a word memory location or register to
  220.           point to a paragraph in memory that contains a data
  221.           structure. Access the structure with expressions like
  222.  
  223.             [abc [xx]:0].mem1
  224.             [abc es:0].mem3
  225.  
  226.   6.  Are there any syntactic or parsing differences between Turbo
  227.       Debugger's Pascal expression evaluation and Borland Pascal's?
  228.  
  229.       a. Turbo Debugger doesn't support expressions for set
  230.          constructors:
  231.  
  232.           OK:   [4..7]
  233.  
  234.           BAD:  [myvar1..myvar2]   [3+4..7+8]
  235.  
  236.       b. You can't pass constant-string arguments when evaluating
  237.          functions or procedures.
  238.  
  239.           OK:   MyFunc(123)   MyFunc(StringVariable)
  240.  
  241.           BAD:  MyFunc('Constant')
  242.  
  243.                 MyFunc(StringConstant), where StringConstant is
  244.                 defined with a "const" declaration and is not a
  245.                 typed constant.
  246.  
  247.       c. You can't evaluate procedures or functions that have
  248.          structure VALUE parameters. You can evaluate procedures or
  249.          functions that have structure VARIABLE parameters, though.
  250.  
  251.   7. What should I be aware of when I'm debugging multilanguage
  252.      programs with Turbo Debugger?
  253.  
  254.      Turbo Debugger's default source language is "Source," which
  255.      means it chooses the expression language based on the current
  256.      source module. This can cause some confusion if your program
  257.      has source modules written in different languages (like Pascal
  258.      and assembler). Since you are actually entering a language
  259.      expression any time Turbo Debugger prompts you for a value
  260.      or an address, you can encounter unexpected results.
  261.  
  262.      a. Even if you are in a CPU window or a Dump window, you
  263.         must still enter addresses in the source language,
  264.         despite the fact that the window displays in hex.
  265.         For example, to display the contents of memory address
  266.         1234:5678, you must type one of the following
  267.         expressions, depending on your current source language:
  268.  
  269.           C            0x1234:0x5678
  270.           Pascal        $1234:$5678
  271.           Assembler     1234H:5678H
  272.  
  273.      b. When your current language is assembler, you must be
  274.         careful when entering hex numbers, since they are
  275.         interpreted EXACTLY as they would be in an assembler
  276.         source file. This means that if you want to enter a
  277.         number that starts with one of the hex digits A - F, you
  278.         must first precede the letter with a 0 so Turbo Debugger
  279.         knows you are entering a number. Likewise, if your
  280.         number ends in B or D (indicating a binary or decimal
  281.         number), you must add an H to indicate that you really want
  282.         a hex number. For example,
  283.  
  284.           OK:   0aaaa   123dh   89abh
  285.  
  286.           BAD:  aaaa    123d    89ab
  287.  
  288.   7. Why does the text "Cannot be changed" come up when I do an
  289.      assignment in the Data|Evaluate|Modify "New value" pane?
  290.  
  291.      If you use the Data|Evaluate|Modify command (Ctrl-F4) to
  292.      change a variable by direct assignment, the "New value" pane
  293.      will say "Cannot be changed." This doesn't mean the
  294.      assignment didn't take effect. What it does mean is that the
  295.      assignment expression as a whole is not a memory-referencing
  296.      expression whose value you can change by moving to the
  297.      bottom pane. Here are some examples of direct assignment
  298.      expressions:
  299.  
  300.        C              x = 4
  301.        Pascal         ratio := 1.234
  302.        Assembler      wval = 4 shl 2
  303.  
  304.      If you had typed just "x", "ratio", or "wval" into the top
  305.      pane, you would be able to move to the bottom pane and
  306.      enter a new value. The direct assignment method using the
  307.      "=" or ":=" assignment operator is quicker and more
  308.      convenient if you don't care about examining the value of
  309.      the variable before modifying it.
  310.  
  311.   8. What is the most likely reason for Turbo Debugger to hang
  312.      when starting up on a PC-compatible computer?
  313.  
  314.      If your computer is a Tandy 1000A, IBM PC Convertible, or NEC
  315.      MultiSpeed, or if Turbo Debugger hangs when loading on your system,
  316.      run TDINST and change an item in the Options|Miscellaneous
  317.      menu so that NMI Intercept isn't set. Some computers use the NMI
  318.      (Non-Maskable Interrupt) in ways that conflict with Turbo Debugger,
  319.      so you must disable Turbo Debugger's use of this interrupt in order
  320.      to run the program.
  321.  
  322.      Also, if you're using an 80386-based machine and have the
  323.      SuperKey utility loaded, be careful not to press a key when
  324.      TD386 is loading, since SuperKey might capture the keystroke
  325.      and cause unexpected results.
  326.  
  327.   9. What could happen when global breakpoints are set on local
  328.      variables?
  329.  
  330.      When you set global breakpoints using local variables, make
  331.      sure the breakpoints are cleared before you exit the
  332.      procedure or function that the variables are defined in. The
  333.      best way to do this is to put a breakpoint on the last line
  334.      of the procedure or function. If you do not clear the
  335.      breakpoints, your program will break unexpectedly and may
  336.      even hang on some machines because the breakpoints are being
  337.      set in memory that is not currently being used by the
  338.      procedure or function.
  339.  
  340.  10. How can I save options set in TDINST to TD286.EXE?
  341.  
  342.      If you have a configuration file (tdconfig.td) already made for
  343.      TD.EXE, TD286.EXE will automatically use this configuration file.
  344.      You can save a configuration made in TDINST to TD286.EXE directly
  345.      if you state this on the command line. For instance,
  346.  
  347.        TDINST TD286.EXE
  348.  
  349.      When you want to save this configuration in TDINST, just select
  350.      Save\Modify td.exe.
  351.  
  352.  11. Why is execution slower when tracing (F7) than when stepping
  353.      (F8) through my programs?
  354.  
  355.      Turbo Debugger can do reverse execution. When you're tracing
  356.      through your program, Turbo Debugger is saving all the information
  357.      about the source line you just traced over. If you want faster
  358.      execution you can (F8) step over the instruction or toggle the
  359.      Full History option to "No" in the Execution History window.
  360.      (Although reverse execution is always available in the CPU
  361.      viewer this option must be toggled to "Yes" to work in the Module
  362.      viewer.  The default setting is "No".)
  363.  
  364.  12. What are some of the issues I should be aware of with TD386?
  365.  
  366.      TD386.EXE is a small kernel program that puts the processor into
  367.      virtual-86 mode, maps one chunk of extended memory into the low
  368.      640K area, and loads TD.EXE into it.  It communicates with TD.EXE
  369.      through the TDH386.SYS device driver.  When instructed to, TD386 maps a
  370.      different chunk of extended memory into the low 640K area. It then
  371.      loads the program to be debugged, into that same area.
  372.  
  373.      The debugging process continues with TD's telling TD386 what to do
  374.      through TDH386.  When any exceptions occur, they are vectored off to
  375.      the resident TD386 code which handles them. TD386 either switches back
  376.      to TD's area and informs TD that an exception occurred or, if TD386
  377.      can't figure out what happened, it simply dumps the registers to
  378.      the screen and halts the CPU (since something bad could have
  379.      happened to cause the exception)
  380.  
  381.      Because TD386 uses the virtual-86 mode of the 80386, it cannot
  382.      coexist with any other programs that put the processor into v-86
  383.      mode.  Programs that simulate EMS memory on a 386 or 486 machine
  384.      usually use virtual-86 mode to do so.  These programs (such as
  385.      QEMM, 386^MAX, CEMM, EMM386,...) are not compatible with TD386.
  386.  
  387.      If you need to use one of these EMS simulators for your program,
  388.      then you should consider using TD286.EXE, which uses a different
  389.      aspect of protected mode and IS compatible with these other
  390.      programs.
  391.  
  392.      Note: HIMEM.SYS does not use virtual-86 mode and behaves
  393.            just fine with TD386.
  394.  
  395.  
  396.      As well as providing a communication path between TD386 and TD,
  397.      TDH386 (the device driver) allows for the use of hardware
  398.      breakpoints.  You can use the hardware breakpoints on any 386 or
  399.      486 machine that has the device driver loaded and is running TD.EXE,
  400.      TD286.EXE, or TD386.EXE.
  401.  
  402.      The only real difference between TD386 and the other two debuggers
  403.      is that TD386 allows some extra breakpoints that the other debuggers
  404.      do not (I/O access breaks, ranges greater than 16 bytes, and so on).
  405.  
  406.      A typical setup would be to load QEMM and then load TDH386.SYS into
  407.      high memory.  With this setup, both TD.EXE and TD286.EXE will support
  408.      hardware breakpoints and will take up the same amount of memory as
  409.      they do without the device driver loaded.
  410.  
  411.      If you are using a SCSI device in your machine and TD386 gives you
  412.      unexpected interrupt reports, make sure that the SCSI device driver
  413.      is protected-mode-aware.  Adaptech SCSI cards come with a driver that
  414.      should work just fine.  IBM PS/2's usually have a driver called
  415.      DISK386.SYS that works in this situation.
  416.  
  417.  13. Why does TD286INS tell me that my A20 line is already enabled?
  418.  
  419.      If you are using a version of DOS that allows you to specify the
  420.      "DOS=HIGH" command in CONFIG.SYS, you won't be able to run
  421.      TD286INS.  What you should do is remove the 'DOS=HIGH' line, then run
  422.      TD286INS, and then replace the "DOS=HIGH" line in CONFIG.SYS.
  423.  
  424.  14. Why do I have mouse problems when debugging Windows programs?
  425.  
  426.      When debugging, the first time you execute a Windows program, the mouse
  427.      will work normally. For the second and subsequent runs, you must press
  428.      any key before the mouse will function. This is a known problem with
  429.      Windows.
  430.  
  431.      When the mouse driver is disabled for Windows, it will be disabled for
  432.      TDW as well.  Starting TDW with the mouse support option (-p) has no
  433.      effect.
  434.  
  435.  
  436. 2. Turbo Debugger for Windows (TDW), Windows debugging hints
  437. ------------------------------------------------------------
  438.   View|Windows Messages
  439.  
  440.       If you set up View|Windows Messages to display messages for
  441.       more than one procedure or handle or both, do not log all
  442.       messages.  Instead, log specific messages for each procedure or
  443.       handle.  If you log all messages, the system might hang, in
  444.       which case you will have to reboot to continue.  This behavior
  445.       is due to the large number of messages being transferred
  446.       between Windows and TDW.
  447.  
  448.       When setting a break on the Mouse class of messages, note that
  449.       a "mouse down" message must be followed by a "mouse up" message
  450.       before the keyboard will become active again.  When you return
  451.       to the application, you might have to press the mouse button
  452.       several times to get Windows to receive a "mouse up" message.
  453.       You'll know Windows has received the message when you see it in the
  454.       bottom pane of the Windows Message window after the program breaks.
  455.  
  456.       If you enter a handle name but indicate that it's a
  457.       procedure, TDW will accept your input and will not complain.
  458.       However, when you run your program, TDW will not log any
  459.       messages.  If TDW is not logging messages when you think you've
  460.       set a handle, check the Add Window dialog box of the top left pane of
  461.       the Windows Messages window to see if you've pressed the Handle button.
  462.  
  463.   View|Module
  464.  
  465.       The Debug Startup radio buttons are used for DLLs only.  To
  466.       debug EXE startup, begin TDW with the Assembler-mode Startup
  467.       command-line option (-l).
  468.  
  469.       When a program loaded into TDW is reset, the Load symbols
  470.       radio buttons default to YES for all DLLs and applications
  471.       with symbols, even if you specified NO for a given DLL or
  472.       application prior to resetting the program.
  473.  
  474.  
  475. 3. TDW mouse support
  476. --------------------
  477.   TDW provides mouse support that allows you to manipulate elements
  478.   of the user interface. Most TDW mouse operations are similar to
  479.   Windows mouse operations. In the material that follows, we discuss
  480.   tips for using a mouse under Windows and some uses of the mouse under
  481.   TDW that are different from Windows mouse usage.
  482.  
  483.   o When the mouse driver is disabled for Windows, it will be disabled
  484.     for TDW as well.  Starting TDW with the mouse support option
  485.     (-p) has no effect unless you enable the Windows mouse driver.
  486.  
  487.   o If you have a mouse driver installed by default, TDW and the
  488.     installation utilities will try to use your mouse. If you
  489.     don't want to use your mouse during a debugging session, you
  490.     can use the command-line switch '-p-' to turn the mouse off.
  491.     You can also set this option in TDWINST in the Options\Input &
  492.     Prompting dialog box.
  493.  
  494.   o When you're debugging a Windows application that uses the mouse
  495.     and you reset the application and then run the program, it won't
  496.     accept mouse clicks until you make a keyboard entry.
  497.  
  498.   o Using the mouse
  499.  
  500.     -  Most mice provide two or three buttons that allow for various
  501.        functions inside an application. With TDW you can, among other
  502.        things, use the left mouse button to select options, move items
  503.        around on the screen, and set breakpoints.
  504.  
  505.     -  Double-clicking the mouse on an item in a list chooses the item.
  506.        For instance, in the File|Open dialog box clicking the mouse once
  507.        just highlights a file. Double-clicking loads the file.
  508.  
  509.     -  The right mouse button has some of the same functionality as the
  510.        left mouse button, but you can also open local menus within TDW
  511.        windows by using this button.
  512.  
  513.   o You can also choose the commands shown at the bottom of the screen,
  514.     like F1-Help, by using the mouse.
  515.  
  516.  
  517. 4. TD mouse support
  518. -------------------
  519.   You use the mouse with TD just as you do with TDW. However, with
  520.   TD you must install a mouse driver, which makes your mouse active
  521.   with TD and other programs. Most mouse drivers will work with TD,
  522.   but might have to be updated to a newer version if you're having
  523.   problems using your current version. If you have problems with the
  524.   mouse after you've loaded TD or TDINST, you might try using the
  525.   Display Swap option that you can specify either in TDINST or on
  526.   the command-line with the -ds switch.
  527.  
  528.   Consult your mouse manual to ensure proper use of the mouse
  529.   and its driver. Early versions of mouse drivers don't support
  530.   screen display modes larger than 80 columns by 24 lines. As a
  531.   result, your mouse driver might not work correctly when you
  532.   use TD's enhanced display modes (EGA 80x43, VGA 80x50, or
  533.   EGA/VGA graphics modes).
  534.  
  535.